package cn.wise.rocketmq.producerdemo1.api._04_push_pull;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class Producer {
    public static void main(String[] args) throws Exception {
        //创建一个生产者对象
        DefaultMQProducer producer = new DefaultMQProducer("wise-producer");
        //2 设置nameserver的地址
        producer.setNamesrvAddr("192.168.147.128:9876;192.168.147.129:9876");
        //启动生产者
        producer.start();
        //创建一个message对象
        Message message = new Message("04-pull-push", "hello,rocketmq".getBytes("utf-8"));
        //使用同步的方式发送
        SendResult sendResult = producer.send(message);
        System.out.println(sendResult.getSendStatus());//打印发送的状态
        //关闭生产者
        producer.shutdown();
    }
}
